package com.ruoyi.resume.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.resume.domain.BoleResumeEducation;
import com.ruoyi.resume.service.IBoleResumeEducationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教育经历Controller
 * 
 * @author ruoyi
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/resume/education")
public class BoleResumeEducationController extends BaseController
{
    @Autowired
    private IBoleResumeEducationService boleResumeEducationService;

    /**
     * 查询教育经历列表
     */
    @PreAuthorize("@ss.hasPermi('resume:education:list')")
    @GetMapping("/list")
    public TableDataInfo list(BoleResumeEducation boleResumeEducation)
    {
        startPage();
        List<BoleResumeEducation> list = boleResumeEducationService.selectBoleResumeEducationList(boleResumeEducation);
        return getDataTable(list);
    }

    /**
     * 导出教育经历列表
     */
    @PreAuthorize("@ss.hasPermi('resume:education:export')")
    @Log(title = "教育经历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BoleResumeEducation boleResumeEducation)
    {
        List<BoleResumeEducation> list = boleResumeEducationService.selectBoleResumeEducationList(boleResumeEducation);
        ExcelUtil<BoleResumeEducation> util = new ExcelUtil<BoleResumeEducation>(BoleResumeEducation.class);
        util.exportExcel(response, list, "教育经历数据");
    }

    /**
     * 获取教育经历详细信息
     */
    @PreAuthorize("@ss.hasPermi('resume:education:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(boleResumeEducationService.selectBoleResumeEducationById(id));
    }

    /**
     * 新增教育经历
     */
    @PreAuthorize("@ss.hasPermi('resume:education:add')")
    @Log(title = "教育经历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BoleResumeEducation boleResumeEducation)
    {
        return toAjax(boleResumeEducationService.insertBoleResumeEducation(boleResumeEducation));
    }

    /**
     * 修改教育经历
     */
    @PreAuthorize("@ss.hasPermi('resume:education:edit')")
    @Log(title = "教育经历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BoleResumeEducation boleResumeEducation)
    {
        return toAjax(boleResumeEducationService.updateBoleResumeEducation(boleResumeEducation));
    }

    /**
     * 删除教育经历
     */
    @PreAuthorize("@ss.hasPermi('resume:education:remove')")
    @Log(title = "教育经历", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(boleResumeEducationService.deleteBoleResumeEducationByIds(ids));
    }
}
